package com.hz.ruoyiequipment.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hz.ruoyiequipment.data.domain.AgrEquipment;
import com.hz.ruoyiequipment.data.domain.vo.CqEquipment;
import com.hz.ruoyiequipment.data.domain.vo.EquipmentWarningSelectVo;
import com.hz.ruoyiequipment.data.domain.vo.QxEquipment;
import com.hz.ruoyiequipment.data.domain.vo.SoilEquipment;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: xqd
 * @CreateDate: 2025/03/07/16:05
 * @Description: 设备表接口
 */
public interface AgrEquipmentMapper extends BaseMapper<SoilEquipment> {
   /**
    * @return: 设备列表集合(公共返回类)
    * @Author: zjk
    * @Date: 2025/3/10 9:03
    * @Description: 查询总设备列表(搜索)
    */

   List<AgrEquipment> selectAgrEquipmentList(AgrEquipment agrEquipment);

    public List<EquipmentWarningSelectVo> selectAgrEquipmentListByTypes(String[] equipmentTypes);

    List<SoilEquipment> getSoilEquipment(
            @Param("equipmentStatus") Integer equipmentStatus,
            @Param("equipmentCode") String equipmentCode,
            @Param("plotsName") String plotsName);

    /**
     * @return:
     * @Author: xqd
     * @Date: 2025/3/8 17:25
     * @Description: 查询气象设备列表(搜索)
     */
    List<QxEquipment> getQxEquipment(QxEquipment qxEquipment);

    /**
     * @return:
     * @Author: xqd
     * @Date: 2025/3/9 16:46
     * @Description: 查询虫情设备列表(搜索)
     */
    List<CqEquipment> getCqEquipment(CqEquipment cqEquipment);

    /**
     * @param equipmentId 设备ID
     * @return: 公共返回类
     * @Author: xqd
     * @Date: 2025/3/7 20:05
     * @Description: 土壤墒情设备信息详情
     */
    SoilEquipment getSoilDetail(Long equipmentId);

 /**
  * @param equipmentId 设备ID
  * @return: 公共返回类
  * @Author: xqd
  * @Date: 2025/3/7 20:05
  * @Description: 气象设备信息详情
  */
    QxEquipment getQxDetail(Long equipmentId);

    /**
     * @return:
     * @Author: xqd
     * @Date: 2025/3/9 16:48
     * @Description: 虫情设备信息详情
     */
    CqEquipment getCqDetail(Long equipmentId);

    /**
     * @param agrEquipment 设备实体类
     * @return: 改变行数（大于0，新增成功）
     * @Author: xqd
     * @Date: 2025/3/8 9:58
     * @Description: 新增设备到设备表
     */
    @Insert("INSERT INTO agr_equipment (equipment_code, equipment_name, equipment_brand, equipment_type, equipment_img)" +
            "Values (#{equipmentCode}, #{equipmentName}, #{equipmentBrand}, #{equipmentType}, #{equipmentImg})")
    @Options(useGeneratedKeys = true, keyProperty = "equipmentId")
    Integer insertAgrEquipment(AgrEquipment agrEquipment);

    /**
     * @param soilEquipment SoilEquipment实体类
     * @return:
     * @Author: xqd
     * @Date: 2025/3/8 16:48
     * @Description: 修改设备表中土壤墒情设备的数据
     */
    Integer updateAgrEquipment(SoilEquipment soilEquipment);

    /**
     * @return:
     * @Author: xqd
     * @Date: 2025/3/8 17:54
     * @Description: 修改设备表中气象设备的数据
     */
    @Update("UPDATE agr_equipment SET equipment_code = #{equipmentCode}, " +
            "equipment_name = #{equipmentName}, " +
            "equipment_brand = #{equipmentBrand}, " +
            "equipment_type = #{equipmentType}, " +
            "equipment_img = #{equipmentImg}, " +
            "equipment_status = #{equipmentStatus} " +
            "WHERE equipment_id = #{equipmentId}")
    void updateAgrEquipmentQx(QxEquipment qxEquipment);

    /**
     * @return:
     * @Author: xqd
     * @Date: 2025/3/9 16:49
     * @Description: 修改设备表中虫情设备的数据
     */
    @Update("UPDATE agr_equipment SET equipment_code = #{equipmentCode}, " +
            "equipment_name = #{equipmentName}, " +
            "equipment_brand = #{equipmentBrand}, " +
            "equipment_type = #{equipmentType}, " +
            "equipment_img = #{equipmentImg}, " +
            "equipment_status = #{equipmentStatus} " +
            "WHERE equipment_id = #{equipmentId}")
    void updateAgrEquipmentCq(CqEquipment cqEquipment);

    /**
     * @param equipmentId 设备ID
     * @return:
     * @Author: xqd
     * @Date: 2025/3/8 16:49
     * @Description: 删除设备表中设备的数据
     */
    @Delete("DELETE FROM agr_equipment WHERE equipment_id = #{equipmentId}")
    void delAgrEquipmentByEquipmentId(Long equipmentId);

    @Select("select count(1) FROM agr_equipment_cq")
    Integer countCq();
    @Select("select count(1) FROM agr_equipment_jk")
    Integer countJk();
    @Select("select count(1) FROM agr_equipment_qx")
    Integer countQx();
    @Select("select count(1) FROM agr_equipment_tr")
    Integer countTr();
    @Select("select count(1) FROM agr_equipment_sf")
    Integer countSf();

}
